Called when user collapses sub-nodes of the node.

<div class="definition">
    onCollapse = function(event)
</div>

You can add event listener during the object creation:

<textarea class="javascript">
let sidebar = new w2sidebar({
    name : 'sidebar',
    nodes: [
        { id: 'id-1', text: 'Level 1' },
        { id: 'id-2', text: 'Level 2' },
        { id: 'id-3', text: 'Level 3' }
    ],
    onCollapse: function(event) {
        console.log(event);
    }
});
</textarea>

or after the object has been created:

<textarea class="javascript">
w2ui.sidebar.on('collapse', function(event) {
    console.log(event);
});
</textarea>

The event handler is called before the default action of the event is triggered. You can cancel the default action by calling
<span class="method">event.preventDefault()</span>. To perform an action
after the event is fully processed, define <span class="method">event.onComplete</span> function.
<div style="height: 10px;"></div>
See <a href="utils/events">events</a> page in utilities for more details.